//
//  ViewController.swift
//  LuckyTurntable
//
//  Created by Yinyin Zeng on 31/5/20.
//  Copyright © 2020 MaoYeYeDeJiangCuCha. All rights reserved.
//

import UIKit

class ViewController: UIViewController {
    
    private let luckyTurntableView = LuckyTurntableView.init(frame: UIScreen.main.bounds)
    
    private let messageArr:[String] = ["姑娘们都喜欢的，她也喜欢，这很正常",
                                        "他们会有疏忽，他们也是普通人",
                                        "丰富多彩的同义词，叫年轻",
                                        "10年可以做很多事，也应该做很多事",
                                        "你知道其中的挣扎，你知道得给自己时间",
                                        "正常的生活，就是对不幸最好的回应",
                                        "请以你的名字呼唤我。"]
    private var index:Int = -1
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.

        self.view.addSubview(luckyTurntableView)
        luckyTurntableView.rotateFinishBlock = { [weak self] in
            
            if let weakSelf = self {
                weakSelf.index += 1
                if weakSelf.index == 7{
                    weakSelf.index = 0
                }
                let alertController = UIAlertController(title: "悄悄话", message: weakSelf.messageArr[weakSelf.index], preferredStyle: UIAlertController.Style.alert)
                let cancelAction = UIAlertAction(title: "一边去", style: UIAlertAction.Style.cancel) { (ACTION) in
                    weakSelf.luckyTurntableView.displayLink.isPaused = false
                }
                let okAction = UIAlertAction(title: "有道理", style: UIAlertAction.Style.default) { (ACTION) in
                    weakSelf.luckyTurntableView.displayLink.isPaused = false
                }
                alertController.addAction(cancelAction)
                alertController.addAction(okAction)
                weakSelf.present(alertController, animated: true, completion: nil)
            }
        }
    }


}

